package com.test.ssm.service.impl;

import com.test.ssm.dao.TeacherDao;
import com.test.ssm.pojo.Teacher;
import com.test.ssm.service.TeacherService;
import com.test.ssm.util.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 徒有琴
 */
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherDao teacherDao;

    @Override
    public Teacher doTeacherLogin(String email, String password) {
        Teacher teacher = teacherDao.getTeacherByEmail(email);
        //因为数据库中是MD5加密的，所以我们需要把用户输入的password加密之后和数据库比较
        if (teacher == null || !teacher.getPassword().equals(DigestUtils.getMD5(password))) {
            return null;
        }
        return teacher;
    }
}
